package com.zlx.guguanjia.mapper;


import com.zlx.guguanjia.entity.SysRole;
import com.zlx.guguanjia.mapper.provider.SysRoleSqlProvider;
import org.apache.ibatis.annotations.*;
import tk.mybatis.mapper.common.Mapper;

import java.util.List;
import java.util.Map;

@org.apache.ibatis.annotations.Mapper
public interface SysRoleMapper extends Mapper<SysRole> {
    @SelectProvider( type= SysRoleSqlProvider.class,method = "selectPage")
    List<SysRole> selectPage(Map<String,Object> map);

    //批量删除
    @DeleteProvider(type = SysRoleSqlProvider.class,method="deleteBatch")
    int deleteBatch(@Param("rid") long rid, @Param("ids") long[] ids);
    //批量添加
    @InsertProvider(type = SysRoleSqlProvider.class,method = "insertBatch")
    int insertBatch(@Param("rid") long rid, @Param("cids") List<Long> cids);

    /**
     * 删除原已选资源
     */
    @Delete("delete from sys_role_resource where role_id=#{rid}")
    int deleteByRid(long rid);

    //批量插入新已选资源
    @InsertProvider(type = SysRoleSqlProvider.class,method = "insertBatchResources")
    int insertBatchResources(@Param("rid")Long rid,@Param("sids") List<Integer> sids);

    /**
     * 删除原已选公司
     */
    @Delete("delete from sys_role_office where role_id=#{rid}")
    int deleteOfficeByRid(long rid);

    /**
     * 批量插入已选公司
     */
    @InsertProvider(type=SysRoleSqlProvider.class,method = "insertRoleOffices")
    int insertRoleOffices(@Param("rid") long rid,@Param("offices") List<Integer> offices);
}